package cn.tedu.yl.campus.service.impl;

import cn.tedu.yl.campus.mapper.CampusMapper;
import cn.tedu.yl.campus.pojo.dto.CampusQuery;
import cn.tedu.yl.campus.pojo.dto.CampusSaveParam;
import cn.tedu.yl.campus.pojo.entity.Campus;
import cn.tedu.yl.campus.pojo.vo.CampusVO;
import cn.tedu.yl.campus.service.CampusService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class CampusServiceImpl implements CampusService {
    @Autowired
    private CampusMapper campusMapper;
    @Override
    public List<CampusVO> select(CampusQuery campusQuery) {
        return campusMapper.select(campusQuery);
    }

    @Override
    public void save(CampusSaveParam campusSaveParam) {
        Campus campus=new Campus();
        BeanUtils.copyProperties(campusSaveParam,campus);
        if (campus.getId()==null){
            campusMapper.insertCampus(campus);
        }
        else {
            campusMapper.updateCampus(campus);
        }
    }
}
